// index.js
const defaultAvatarUrl = 'https://mmbiz.qpic.cn/mmbiz/icTdbqWNOwNRna42FI242Lcia07jQodd2FJGIYQfG0LAJGFxM4FbnQP6yfMxBgJ0F3YRqJCJ1aPAK2dQagdusBZg/0'

Page({
  data: {
    highScore: 0
  },

  onLoad() {
    console.log('首页加载');
    // 从本地存储加载最高分
    const highScore = wx.getStorageSync('highScore') || 0;
    this.setData({
      highScore
    });
  },

  startGame() {
    console.log('点击开始游戏');
    wx.navigateTo({
      url: '/pages/game/game',
      success: function() {
        console.log('导航成功');
      },
      fail: function(err) {
        console.error('导航失败：', err);
        wx.showToast({
          title: '页面跳转失败',
          icon: 'none'
        });
      }
    });
  },

  goToSettings() {
    console.log('点击设置');
    wx.navigateTo({
      url: '/pages/settings/settings',
      success: function() {
        console.log('导航成功');
      },
      fail: function(err) {
        console.error('导航失败：', err);
        wx.showToast({
          title: '页面跳转失败',
          icon: 'none'
        });
      }
    });
  }
});
